<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	</head>
	<body>
		<div id="app">
			<cpt1></cpt1>
			<cpt2></cpt2>
		</div>
		<template id="c1">
			<div>
				<h3>{{name}}</h3>
				<h5>{{cp1}}</h5>
				<button @click="setDate">c1组件</button>
			</div>
		</template>
		<template id="c2">
			<div>
				<hr />
				<h3>{{name}}</h3>
				<!-- <h5>{{cp1}}</h5> -->
				<button @click="getData">c2组件</button>
			</div>
		</template>
		<script type="text/javascript">
			const vm = new Vue({
				el: '#app',
				components: {
					cpt1: {
						template: '#c1',
						data() {
							return {
								name: '组件1',
								cp1: '博为峰'
							}
						},
						methods: {
							setDate() {
								this.bwf.cp1 = this.cp1;
							}
						}
					},
					cpt2: {
						template: '#c2',
						data() {
							return {
								name: '组件2'
							}
						},
						methods: {
							getData() {
								console.log(this.bwf.cp1);
							}
						}
					}
				}
			});
			console.log(vm);
			// console.log(vm.$children[0]);
			// Vue.prototype.bwf = vm;
			Vue.prototype.bwf = {};
			
			// console.log(Vue.prototype === vm.$children[0].__proto__.__proto__)
		</script>
	</body>
</html>
